<?php
class Menu extends MY_Controller{
	
	function __construct()
	{
		parent::__construct();
	}
	
	function index()
	{	$cat_id = $this->uri->segment(2);
		if($cat_id == ''){
			$cat_id = 1;
		}
		$data['title'] = $this->title('Menu');
		$data['menu'] = cat::find('all',array('conditions'=>array('parent_id'=> NULL)));
		$submenu = cat::find('all',array('conditions'=>'parent_id='.$cat_id));
		if($submenu){
			redirect('menu/'.$cat_id.'/'.$submenu[0]->id);
		}else{
		$data['submenu'] = $submenu;	
		}
		$data['files'] = get_dir_file_info('lunch_pdf', $top_level_only = TRUE);
		$data['product'] = product::find('all',array('conditions'=>array('cat_id'=>$cat_id,'status'=> ! null)));
		$data['sauces'] = product::find('all',array('conditions'=>array('cat_id'=>16,'status'=>! null)));
		$data['shop'] = shop::find('all',array('conditions'=>array('status','1')));
		$this->load->view('header',$data);
		$this->load->view('menu');
		$this->load->view('footer');
	}
	
	function submenu()
	{
		$data['files'] = get_dir_file_info('lunch_pdf', $top_level_only = TRUE);
		$data['title'] = $this->title('Menu');
		$parent_id = $this->uri->segment(2);
		$cat_id = $this->uri->segment(3);
		$data['comewith'] = comewith::find('all');
		$data['menu'] = cat::find('all',array('conditions'=>array('parent_id'=>NULL)));
		$data['submenu'] = cat::find('all',array('conditions'=>'parent_id='.$parent_id));
		$data['product'] = product::find('all',array('conditions'=>array('cat_id'=>$cat_id,'status'=> ! null)));
		$data['sauces'] = product::find('all',array('conditions'=>array('cat_id'=>16,'status'=>! null)));
		$data['shop'] = shop::find('all',array('conditions'=>array('status','1')));
		$this->load->view('header',$data);
		$this->load->view('submenu');
		$this->load->view('footer');
	}
	
	
	
	
	
}